import request from '@/utils/request'

/**
 * 字典类型管理API接口
 */

// 分页查询字典类型列表
export function getDictTypePage(currentPage, pageSize, queryData) {
  return request({
    url: `/api/dict-type/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 根据ID查询字典类型详情
export function getDictTypeById(dictTypeId) {
  return request({
    url: `/api/dict-type/${dictTypeId}`,
    method: 'get'
  })
}

// 根据字典类型获取字典类型信息
export function getDictTypeByType(dictType) {
  return request({
    url: `/api/dict-type/type/${dictType}`,
    method: 'get'
  })
}

// 获取所有启用的字典类型
export function getAllEnabledDictTypes() {
  return request({
    url: '/api/dict-type/all-enabled',
    method: 'get'
  })
}

// 根据名称模糊查询字典类型
export function getDictTypesByName(dictName) {
  return request({
    url: '/api/dict-type/search',
    method: 'get',
    params: { dictName }
  })
}

// 新增字典类型
export function addDictType(dictTypeData) {
  return request({
    url: '/api/dict-type',
    method: 'post',
    data: dictTypeData
  })
}

// 更新字典类型
export function updateDictType(dictTypeData) {
  return request({
    url: '/api/dict-type',
    method: 'put',
    data: dictTypeData
  })
}

// 删除字典类型
export function deleteDictType(dictTypeId) {
  return request({
    url: `/api/dict-type/${dictTypeId}`,
    method: 'delete'
  })
}

// 批量删除字典类型
export function batchDeleteDictTypes(dictTypeIds) {
  return request({
    url: '/api/dict-type/batch',
    method: 'delete',
    data: dictTypeIds
  })
}

// 修改字典类型状态
export function updateDictTypeStatus(dictTypeId, status) {
  return request({
    url: `/api/dict-type/${dictTypeId}/status`,
    method: 'put',
    params: { status }
  })
}

// 刷新字典缓存
export function refreshDictCache() {
  return request({
    url: '/api/dict-type/refresh-cache',
    method: 'post'
  })
}

// 检查字典类型是否存在
export function checkDictTypeExists(dictType, excludeId) {
  return request({
    url: '/api/dict-type/check-type',
    method: 'get',
    params: { dictType, excludeId }
  })
}